<?php
define('IN_YCTOOL', true);//定义该文件合法性
require_once('config.php');
require_once('config2.php');

require_once(DIR_COMM . 'common.php');

	session_start();

	if(!isset($_SESSION['user_login']) || $_SESSION['user_login']!='Y'){
		header('location:index.php');
        }
     
if($_POST['ordercode'])
{ 
    $ordercode=htmlspecialchars(trim($_POST['ordercode']));
  
    if($_POST['userid'])
    {  
        if(db::insert('tao_userorder',array('userid' => $_POST['userid'] ,'ordercode' => $ordercode),'1'))
        {
            
            func::obHeader('http://'.$_SERVER['SERVER_NAME'].'/taotao/user_center.php');
        }
    }
    else
    {
        func::obHeader('http://sso.p.cn/cuo/login?service=http://'.$_SERVER['SERVER_NAME'].'/taotao/index.php');
    }

}

$action = $_GET['action'];
!$action&&$action = 'channelorder';
$page = $_GET['page'];
!$page&&$page=1;
$per = 12;
 

if($action == 'channelorder')
{ 
    $getcode = $_POST['getcode'];
    $strs  =  'userid='.$_SESSION['user_uid'];
    if($getcode)
    {
        $strs .= ' AND ordercode=\''.trim($getcode).'\' ORDER BY regtime';
    }
 
    $rslist = db::getLimit('tao_userorder','*',$strs,$page, $per); 
    $count = db::getCount('tao_userorder', '*', 'userid='.$_SESSION['user_uid']);
    !$count && $count=0;
    $rslist = func::htmlspecialcharsArray($rslist);
    if(!$rslist)
    {
        $rslist = array();
    }
    $pagestr = func::pageStr($count, $page, $per,'user_center.php?');
}
if($action == 'getorder')
{
    if(!$rslist)
    {
        $rslist = array();
    }
}
require_once DIR_COMM.'template.func.php';
require_once tpl('user_center.html');
exit;
?>
 
